package com.soecode.lyf.web;

import com.soecode.lyf.dto.Result;
import com.soecode.lyf.entity.Book;
import com.soecode.lyf.service.BookService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;


/**
 * @author: chenhs
 * @date: Created in 11:01 2020/2/27
 **/
@Api(tags={"书刊借阅接口"})
@RestController
@RequestMapping("/api/newBook")
public class NewBookController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private BookService bookService;

    @ApiOperation(value = "书籍清单", notes = "书刊")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    private Result list(Model model) {
        List<Book> list = bookService.getList();
        return new Result(true, list);
    }

    @ApiOperation(value = "书刊详情", notes = "书刊")
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    private Result detail(@ApiParam(value = "书刊ID", required = true) @RequestParam(value = "bookId") Long bookId) {
        Book book = bookService.getById(bookId);
        return new Result(true, book);
    }

}


